//
//  CommunityViewController.m
//  OtherDemo
//
//  Created by lianjie on 2018/7/23.
//  Copyright © 2018年 lianjie. All rights reserved.
//

#import "DEWCommunityViewController.h"
#import "DEWRingBtnTableViewCell.h"
#import "UIBarButtonItem+MainBar.h"
#import "DEWChangeVRingView.h"
#import "DEWRingInfoTableViewCell.h"
//选择圈子发布
#import "DEWPopRingView.h"

static NSString *const RingInfoCellID = @"RingInfo";

@interface DEWCommunityViewController ()<UITableViewDelegate,UITableViewDataSource>

/** tableView */
@property (strong, nonatomic) UITableView *tableView;

@end

@implementation DEWCommunityViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self loadData];
    
    [self createView];
    
}

#pragma mark ----RequestData
-(void)loadData
{
    
    
}


#pragma mark ----initView
-(void)createView
{
    NSMutableArray *ringArr = [NSMutableArray arrayWithObjects:@"榆林老乡",@"IT同行",@"80后",@"90后",@"00后",@"10后",@"宝妈",@"70后", nil];
    //选择关注的圈子
//    [DEWChangeVRingView showChangeRingViewDataArr:@[]];
    //发布时选择的圈子
    [DEWPopRingView showPopRingViewDataArr:ringArr pushbtnBlock:^(NSString *str, NSInteger index) {
        NSLog(@"%@=== %ld",str,index);
    }];
    
    
    self.navigationItem.title = @"同类圈子";
    
    UIBarButtonItem *rightItem = [UIBarButtonItem itemWithTarget:self action:@selector(rightBarButtonItemClick) image:@"圈子-搜索" highImage:@"圈子-搜索" andTitle:nil];
    self.navigationItem.rightBarButtonItem = rightItem;
    
    [self creatTab];
    
    
    
}
#pragma mark - 导航搜索按钮点击事件
-(void)rightBarButtonItemClick{
    NSLog(@"点击了搜索按钮");
}
-(void)creatTab{
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, DEWScreenWidth , DEWScreenHeight - NAVH) style:UITableViewStyleGrouped];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:_tableView];
    if (@available(iOS 11.0, *)){
        _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        self.tableView.estimatedRowHeight = 0;
        self.tableView.estimatedSectionHeaderHeight = 0;
        self.tableView.estimatedSectionFooterHeight = 0;
    }
    
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([DEWRingInfoTableViewCell class]) bundle:nil] forCellReuseIdentifier:RingInfoCellID];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 20;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        DEWRingBtnTableViewCell *cell = [[DEWRingBtnTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ringCell"];
        
        return cell;
    }else{
        
        DEWRingInfoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:RingInfoCellID];
        
        
        
        return cell;
        
    }
    
    return nil;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 250;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.001;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, DEWScreenWidth , 10)];
    lineView.backgroundColor = [UIColor groupTableViewBackgroundColor];
//    [cell addSubview:lineView];
    return lineView;
}

#pragma mark ---lazy

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
